package com.example.advice;


import com.example.util.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class CommonExceptionHandle {

    @ExceptionHandler(NullPointerException.class)
    public Result nullPointerExceptionHandler(NullPointerException e){
        e.printStackTrace(); //打印异常堆栈信息
        return new Result("444","空指针");
    }

    @ExceptionHandler(ArithmeticException.class)
    public Result arithmeticExceptionHandler(NullPointerException e){
        e.printStackTrace(); //打印异常堆栈信息
        return new Result("445","算数异常");
    }
}
